Skip to content

fix(landing): load sharp lazily so a missing native binary can't 500 /blog and /library - #6496

Merged
waleedlatif1 merged 1 commit into
stagingfrom
worktree-nav-grid-and-blog-fix
Aug 10, 2026
Merged

fix(landing): load sharp lazily so a missing native binary can't 500 /blog and /library#6496
waleedlatif1 merged 1 commit into
stagingfrom
worktree-nav-grid-and-blog-fix

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • /blog, /library, and every tag, author, slug, and RSS route under them are returning 500 in production. Root cause confirmed in CloudWatch: Failed to load external module sharp — ERR_DLOPEN_FAILED: libvips-cpp.so.8.18.3: cannot open shared object file, thrown from externalImport with no catch frame.
  • chore(deps): drop the archived image-size dependency #6485 replaced image-size with sharp and imported it at the top level of lib/content/registry-factory.ts. sharp's native binary is not present in the runtime image, so that import throws at module scope and takes down every route that touches the content registry — instead of degrading one optional OG dimension.
  • Load sharp lazily inside the existing try, matching the guarded dynamic import lib/copilot/vfs/file-reader.ts already uses against this exact failure. Log the fallback instead of swallowing it silently.
  • Nav mega-menu: drop the 6-track/col-start-2 centering so the Platform menu's five tiles leave their gap in the bottom-right corner rather than staggering.

Follow-ups (not in this PR)

  • This contains the outage; it does not restore sharp. Prod genuinely cannot load libvips, which also means Copilot's VFS image handling is silently degraded there. OG dimensions fall back to 1200x630 until the runtime image ships the native binary — outputFileTracingIncludes globs ./node_modules/sharp/**/* and ./node_modules/@img/**/*, but those resolve against apps/sim while both hoist to the monorepo root, so they match nothing (same trap docker/app.Dockerfile already documents for yjs/lib0).

Type of Change

  • Bug fix

Testing

  • New lib/content/registry-factory.test.ts mocks sharp to fail exactly as production does; verified it goes red on the current code (module-load throw, 0 tests run) and green with the fix.
  • bun run type-check, bun run lint, and bunx vitest run lib/content (44 passed).
  • Nav grid change verified by code, not visually — the dev server won't run in a worktree (Turbopack root + hoisted node_modules).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 10, 2026 5:38pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents a missing Sharp native binary from taking down landing-page content routes and simplifies the Platform navigation grid.

  • Moves Sharp loading into the existing per-image error boundary and logs dimension-read failures before falling back to default OG dimensions.
  • Adds regression tests covering registry listing and slug lookup when Sharp cannot load.
  • Replaces the six-track navigation layout with a reading-order three-column grid.

Confidence Score: 5/5

The PR appears safe to merge, with Sharp load failures contained as intended and no actionable regressions identified.

The lazy import and metadata extraction execute within the same error boundary, the fallback behavior is regression-tested, and the navigation change is a self-contained layout simplification.

Important Files Changed

Filename Overview
apps/sim/lib/content/registry-factory.ts Lazily imports Sharp within the existing fallback boundary, ensuring native-module failures no longer prevent content registries from loading.
apps/sim/lib/content/registry-factory.test.ts Adds focused regression coverage proving registry listing and slug resolution survive a Sharp import failure.
apps/sim/app/(landing)/components/navbar/components/nav-menu-chip/nav-menu-chip.tsx Simplifies the menu layout to a conventional three-column grid that leaves incomplete-row space at the bottom right.
apps/sim/app/(landing)/components/navbar/components/nav-menu-chip/constants.ts Updates Platform-menu documentation to match the five-item, three-column layout.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Content registry reads post frontmatter] --> B{OG image is local}
  B -- No --> C[Skip dimension extraction]
  B -- Yes --> D[Read image file]
  D --> E[Lazy import Sharp]
  E -->|Available| F[Extract width and height]
  E -->|Missing native binary| G[Log warning]
  D -->|Read failure| G
  F --> H[Return dimensions]
  G --> I[Return null]
  I --> J[Use default OG dimensions]
  C --> J
Loading

Reviews (1): Last reviewed commit: "fix(landing): load sharp lazily so a mis..." | Re-trigger Greptile

@cursor

cursor Bot commented Aug 10, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches the shared content registry used across blog/library and RSS routes, but the change is defensive (lazy import + contained failure) with new regression tests; nav layout is cosmetic only.

Overview
Fixes production 500s on /blog, /library, and related RSS/tag/author routes caused by a top-level sharp import in registry-factory.ts. When the runtime image lacks the native libvips binary, module load fails and takes down every route that touches the content registry—not just OG metadata.

readOgImageDimensions now dynamically imports sharp inside the existing try, so a missing binary only drops optional ogImageWidth/ogImageHeight (builders still fall back to 1200×630). Failures are logged via getErrorMessage instead of being swallowed silently.

Adds registry-factory.test.ts that mocks sharp to fail like production; asserts listing and slug resolution still work with dimensions omitted.

Landing nav: the mega-menu panel drops the six-track grid and col-start-2 centering for short rows. It uses a plain grid-cols-3 so five Platform tiles leave an empty cell in the bottom-right (comment in constants.ts updated).

Reviewed by Cursor Bugbot for commit cd4f714. Configure here.

@waleedlatif1
waleedlatif1 merged commit 52ee2a5 into staging Aug 10, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-nav-grid-and-blog-fix branch August 10, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant